<?php
/**
 * 运行框架
 *
 * @copyright  Copyright (c) 2015-2025 NcPHP Inc. (http://www.ncphp.com)
 * @link       http://www.ncphp.com/
 * @author     NcPHP Team
 * @since      File available since Release v1.2
 */

defined('InNcPHP') or exit('Access Invalid!');

if (!@include(BASE_CORE_PATH.'/config/config.ini.php')) exit('config.ini.php isn\'t exists!');
if (file_exists(BASE_PATH.'/config/config.ini.php')){include(BASE_PATH.'/config/config.ini.php');}
global $config;
// --- ---
define('URL_MODEL',			$config['url_model']);
// --- ---
define('ADMIN_SITE_URL',	$config['admin_site_url']);
define('UPLOAD_SITE_URL',	$config['upload_site_url']);
// --- ---
define('BASE_DATA_PATH',	BASE_ROOT_PATH.DS.DIR_DATA);
define('BASE_UPLOAD_PATH',	BASE_ROOT_PATH.DS.DIR_UPLOAD);
// --- ---
define('CHARSET',			$config['db'][1]['dbcharset']);
define('DBDRIVER',			$config['dbdriver']);
define('SESSION_EXPIRE',	$config['session_expire']);
define('LANG_TYPE',			$config['lang_type']);
define('COOKIE_PRE',		$config['cookie_pre']);
define('DBPRE',				($config['db'][1]['dbname']).'`.`'.($config['tablepre']));
// --- ---
$_GET['act'] 	= $_GET['act'] ? strtolower($_GET['act']) : ($_POST['act'] ? strtolower($_POST['act']) : null);
$_GET['op'] 	= $_GET['op'] ? strtolower($_GET['op']) : ($_POST['op'] ? strtolower($_POST['op']) : null);
if(empty($_GET['act'])){
    require_once(BASE_CORE_PATH.'/framework/core/route.php');
    new Route($config);
}
// ACTION
$_GET['act'] 	= preg_match('/^[\w]+$/i',$_GET['act']) ? $_GET['act'] : 'index';
$_GET['op'] 	= preg_match('/^[\w]+$/i',$_GET['op']) ? $_GET['op'] : 'index';
//对GET POST接收内容进行过滤,$ignore内的下标不被过滤
$ignore 		= array('content','ref_url', 'content1','content2');
if (!class_exists('Security')) require(BASE_CORE_PATH.'/framework/libraries/security.php');
$_GET 			= !empty($_GET) ? Security::getAddslashesForInput($_GET,$ignore) : array();
$_POST 			= !empty($_POST) ? Security::getAddslashesForInput($_POST,$ignore) : array();
$_REQUEST 		= !empty($_REQUEST) ? Security::getAddslashesForInput($_REQUEST,$ignore) : array();
$_SERVER 		= !empty($_SERVER) ? Security::getAddSlashes($_SERVER) : array();
//启用ZIP压缩
if ($config['gzip'] == 1 && function_exists('ob_gzhandler') && $_GET['inajax'] != 1){
	ob_start('ob_gzhandler');
}else {
	ob_start();
}
// --- ---
require_once(BASE_CORE_PATH.'/framework/function/public.php');
require_once(BASE_CORE_PATH.'/framework/function/core.php');
require_once(BASE_CORE_PATH.'/framework/core/base.php');
require_once(BASE_CORE_PATH.'/framework/core/agent.php');
// --- ---
if (function_exists('spl_autoload_register')) {
	spl_autoload_register(array('Base', 'autoload'));
} else {
	function __autoload($class) {
		return Base::autoload($class);
	}
}
?>